package com.hw.springcloud.service;

import com.hw.springcloud.entities.CommonResult;
import com.hw.springcloud.entities.Payment;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * @Classname: PaymentOpenFeignService
 * @Description: OpenFeign接口  需要加上@FeignClient注解,里面的值是服务名称,这里使用eureka的服务,
 *                             所以写eureka上的服务名称CLOUD-PAYMENT-SERVICE
 * @Date: 2021/8/16
 * @Author: huwei
 */
@Component
@FeignClient(value = "CLOUD-PAYMENT-SERVICE")
public interface PaymentOpenFeignService {

    /**
     * 使用CLOUD-PAYMENT-SERVICE服务下的getById方法,因为payment8001和payment8002都注册进了eureka
     * 且名称叫CLOUD-PAYMENT-SERVICE,所以会找这两个下面的getById方法
     *
     * @GetMapping记得要加上Controller前的@RequestMapping部分否则会报错404,找不到方法
     *
     * @param id
     * @return
     */
    @GetMapping( "/payment/getById/{id}")
    CommonResult<Payment> getById(@PathVariable("id") Long id);

    /**
     * 测试链接超时方法
     * @return
     */
    @GetMapping("/payment/timeout")
    String timeout();

}